home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 21 / Cream of the Crop 21 (Terry Blount) (October 1996).iso / doom / qplus10.zip / WEAPONS.QC < prev    next >
Text File  |  1996-08-18  |  30KB  |  1,427 lines

  1. /*
  2. */
  3. void (entity targ, entity inflictor, entity attacker, float damage) T_Damage;
  4. void () player_run;
  5. void(entity bomb, entity attacker, float rad, entity ignore) T_RadiusDamage;
  6. void(vector org, vector vel, float damage) SpawnBlood;
  7. void() SuperDamageSound;
  8.  
  9.  
  10. // called by worldspawn
  11. void() W_Precache =
  12. {
  13.     precache_sound ("weapons/r_exp3.wav");    // new rocket explosion
  14.     precache_sound ("weapons/rocket1i.wav");    // spike gun
  15.     precache_sound ("weapons/sgun1.wav");
  16.     precache_sound ("weapons/guncock.wav");    // player shotgun
  17.     precache_sound ("weapons/ric1.wav");    // ricochet (used in c code)
  18.     precache_sound ("weapons/ric2.wav");    // ricochet (used in c code)
  19.     precache_sound ("weapons/ric3.wav");    // ricochet (used in c code)
  20.     precache_sound ("weapons/spike2.wav");    // super spikes
  21.     precache_sound ("weapons/tink1.wav");    // spikes tink (used in c code)
  22.     precache_sound ("weapons/grenade.wav");    // grenade launcher
  23.     precache_sound ("weapons/bounce.wav");        // grenade bounce
  24.     precache_sound ("weapons/shotgn2.wav");    // super shotgun
  25.     precache_sound ("zombie/z_hit.wav");    // Axe
  26. };
  27.  
  28. float() crandom =
  29. {
  30.     return 2*(random() - 0.5);
  31. };
  32.  
  33. /*
  34. ================
  35. W_FireAxe
  36. ================
  37. */
  38. void(entity newfriend) player_addfriend;        //ws
  39.  
  40. void() W_FireAxe =
  41. {
  42.     local    vector    source;
  43.     local    vector    org;
  44.     local     entity    trace_ent, oldself;    //ws
  45.  
  46.     source = self.origin + '0 0 16';
  47.     traceline (source, source + v_forward*64, FALSE, self);
  48.     if (trace_fraction == 1.0)
  49.         return;
  50.     
  51.     org = trace_endpos - v_forward*4;
  52.  
  53.     if (trace_ent.takedamage)
  54.     {
  55.         sound (self, CHAN_WEAPON, "zombie/z_hit.wav", 1, ATTN_NORM);
  56.         // Some sort of thunking sound ...
  57.         trace_ent.axhitme = 1;
  58.         if (trace_ent.classname == "monster_dog" || trace_ent.classname == "monster_army")    //ws...
  59.         {                                    
  60.         trace_ent.flags & FL_FRIENDLY;
  61.         trace_ent.touch=FriendMove;
  62.         trace_ent.friend=trace_ent.enemy;
  63.         oldself=trace_ent;
  64.         trace_ent=trace_ent.friend;
  65.         player_addfriend(oldself);
  66.         trace_ent=oldself;
  67.         }
  68.         else                    //...ws                
  69.         SpawnBlood (org, '0 0 0', 20);        
  70.         T_Damage (trace_ent, self, self, 20);
  71.     }
  72.     else
  73.     {    // hit wall
  74.         sound (self, CHAN_WEAPON, "player/axhit2.wav", 1, ATTN_NORM);
  75.         WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  76.         WriteByte (MSG_BROADCAST, TE_GUNSHOT);
  77.         WriteCoord (MSG_BROADCAST, org_x);
  78.         WriteCoord (MSG_BROADCAST, org_y);
  79.         WriteCoord (MSG_BROADCAST, org_z);
  80.     }
  81. };
  82.  
  83.  
  84. //============================================================================
  85.  
  86.  
  87. vector() wall_velocity =
  88. {
  89.     local vector    vel;
  90.     
  91.     vel = normalize (self.velocity);
  92.     vel = normalize(vel + v_up*(random()- 0.5) + v_right*(random()- 0.5));
  93.     vel = vel + 2*trace_plane_normal;
  94.     vel = vel * 200;
  95.     
  96.     return vel;
  97. };
  98.  
  99.  
  100. /*
  101. ================
  102. SpawnMeatSpray
  103. ================
  104. */
  105. void(vector org, vector vel) SpawnMeatSpray =
  106. {
  107.     local    entity missile, mpuff;
  108.     local    vector    org;
  109.  
  110.     missile = spawn ();
  111.     missile.owner = self;
  112.     missile.movetype = MOVETYPE_BOUNCE;
  113.     missile.solid = SOLID_NOT;
  114.  
  115.     makevectors (self.angles);
  116.  
  117.     missile.velocity = vel;
  118.     missile.velocity_z = missile.velocity_z + 250 + 50*random();
  119.  
  120.     missile.avelocity = '3000 1000 2000';
  121.     
  122. // set missile duration
  123.     missile.nextthink = time + 30;
  124.     missile.think = SUB_Remove;
  125.  
  126.     setmodel (missile, "progs/zom_gib.mdl");
  127.     setsize (missile, '0 0 0', '0 0 0');        
  128.     setorigin (missile, org);
  129. };
  130.  
  131. /*
  132. ================
  133. SpawnBlood
  134. ================
  135. */
  136. void(vector org, vector vel, float damage) SpawnBlood =
  137. {
  138.     if (trace_ent.flags & FL_OBJECT || self.flags & FL_OBJECT || other.flags & FL_OBJECT )    //ws...
  139.             particle (org, vel*0.1, 10, damage*2);    
  140.     else particle (org, vel*0.1, 73, damage*2);                        //...ws
  141. };
  142.  
  143. /*
  144. ================
  145. spawn_touchblood
  146. ================
  147. */
  148. void(float damage) spawn_touchblood =
  149. {
  150.     local vector    vel;
  151.  
  152.     vel = wall_velocity () * 0.2;
  153.     SpawnBlood (self.origin + vel*0.01, vel, damage);
  154. };
  155.  
  156.  
  157. /*
  158. ================
  159. SpawnChunk
  160. ================
  161. */
  162. void(vector org, vector vel) SpawnChunk =
  163. {
  164.     particle (org, vel*0.02, 0, 10);
  165. };
  166.  
  167. /*
  168. ==============================================================================
  169.  
  170. MULTI-DAMAGE
  171.  
  172. Collects multiple small damages into a single damage
  173.  
  174. ==============================================================================
  175. */
  176.  
  177. entity    multi_ent;
  178. float    multi_damage;
  179.  
  180. void() ClearMultiDamage =
  181. {
  182.     multi_ent = world;
  183.     multi_damage = 0;
  184. };
  185.  
  186. void() ApplyMultiDamage =
  187. {
  188.     if (!multi_ent)
  189.         return;
  190.     T_Damage (multi_ent, self, self, multi_damage);
  191. };
  192.  
  193. void(entity hit, float damage) AddMultiDamage =
  194. {
  195.     if (!hit)
  196.         return;
  197.     
  198.     if (hit != multi_ent)
  199.     {
  200.         ApplyMultiDamage ();
  201.         multi_damage = damage;
  202.         multi_ent = hit;
  203.     }
  204.     else
  205.         multi_damage = multi_damage + damage;
  206. };
  207.  
  208. /*
  209. ==============================================================================
  210.  
  211. BULLETS
  212.  
  213. ==============================================================================
  214. */
  215.  
  216. /*
  217. ================
  218. TraceAttack
  219. ================
  220. */
  221. void(float damage, vector dir) TraceAttack =
  222. {
  223.     local    vector    vel, org;
  224.     
  225.     vel = normalize(dir + v_up*crandom() + v_right*crandom());
  226.     vel = vel + 2*trace_plane_normal;
  227.     vel = vel * 200;
  228.  
  229.     org = trace_endpos - dir*4;
  230.  
  231.     if (trace_ent.takedamage)
  232.     {
  233.         SpawnBlood (org, vel*0.2, damage);
  234.         AddMultiDamage (trace_ent, damage);
  235.     }
  236.     else
  237.     {
  238.         WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  239.         WriteByte (MSG_BROADCAST, TE_GUNSHOT);
  240.         WriteCoord (MSG_BROADCAST, org_x);
  241.         WriteCoord (MSG_BROADCAST, org_y);
  242.         WriteCoord (MSG_BROADCAST, org_z);
  243.     }
  244. };
  245.  
  246. /*
  247. ================
  248. FireBullets
  249.  
  250. Used by shotgun, super shotgun, and enemy soldier firing
  251. Go to the trouble of combining multiple pellets into a single damage call.
  252. ================
  253. */
  254. void(float shotcount, vector dir, vector spread) FireBullets =
  255. {
  256.     local    vector direction;
  257.     local    vector    src;
  258.     
  259.     makevectors(self.v_angle);
  260.  
  261.     src = self.origin + v_forward*10;
  262.     src_z = self.absmin_z + self.size_z * 0.7;
  263.  
  264.     ClearMultiDamage ();
  265.     while (shotcount > 0)
  266.     {
  267.         direction = dir + crandom()*spread_x*v_right + crandom()*spread_y*v_up;
  268.  
  269.         traceline (src, src + direction*2048, FALSE, self);
  270.         if (trace_fraction != 1.0)
  271.             TraceAttack (4, direction);
  272.  
  273.         shotcount = shotcount - 1;
  274.     }
  275.     ApplyMultiDamage ();
  276. };
  277.  
  278. /*
  279. ================
  280. W_FireShotgun
  281. ================
  282. */
  283. void() W_FireShotgun =
  284. {
  285.     local vector dir;
  286.  
  287.     sound (self, CHAN_WEAPON, "weapons/guncock.wav", 1, ATTN_NORM);    
  288.  
  289.     self.punchangle_x = -2;
  290.     
  291.     self.currentammo = self.ammo_shells = self.ammo_shells - 1;
  292.     dir = aim (self, 100000);
  293.     FireBullets (6, dir, '0.04 0.04 0');
  294. };
  295.  
  296.  
  297. /*
  298. ================
  299. W_FireSuperShotgun
  300. ================
  301. */
  302. void() W_FireSuperShotgun =
  303. {
  304.     local vector dir;
  305.  
  306.     if (self.currentammo == 1)
  307.     {
  308.         W_FireShotgun ();
  309.         return;
  310.     }
  311.         
  312.     sound (self ,CHAN_WEAPON, "weapons/shotgn2.wav", 1, ATTN_NORM);    
  313.  
  314.     self.punchangle_x = -4;
  315.     
  316.     self.currentammo = self.ammo_shells = self.ammo_shells - 2;
  317.     dir = aim (self, 100000);
  318.     FireBullets (14, dir, '0.14 0.08 0');
  319. };
  320.  
  321.  
  322. /*
  323. ==============================================================================
  324.  
  325. ROCKETS
  326.  
  327. ==============================================================================
  328. */
  329. void() flare_bright;
  330. void() flare_dim;
  331.  
  332. void()    s_explode1    =    [0,        s_explode2] {};
  333. void()    s_explode2    =    [1,        s_explode3] {};
  334. void()    s_explode3    =    [2,        s_explode4] {};
  335. void()    s_explode4    =    [3,        s_explode5] {};
  336. void()    s_explode5    =    [4,        s_explode6] {};
  337. void()    s_explode6    =    [5,        SUB_Remove] {};
  338.  
  339. void() BecomeExplosion =
  340. {
  341.     self.movetype = MOVETYPE_NONE;
  342.     self.velocity = '0 0 0';
  343.     self.touch = SUB_Null;
  344.     setmodel (self, "progs/s_explod.spr");
  345.     self.solid = SOLID_NOT;
  346.     s_explode1 ();
  347. };
  348.  
  349. /*
  350. ==============================
  351. flare_bright()
  352. This function makes the flare
  353. emit brighter light
  354. ==============================
  355. */
  356.  
  357. void() flare_bright =
  358. {
  359.     local vector    vel;
  360.     self.effects=EF_BRIGHTLIGHT;
  361.     self.nextthink = time + 5;
  362.     self.think = flare_dim;
  363.     sound (self, CHAN_WEAPON, "misc/power.wav", 1, ATTN_NORM);
  364. // Set up some red and yellow sparks
  365.     vel = '0 0 150';
  366.     particle (self.origin+vel*0.01,vel,111,150);
  367.     vel = '0 0 120';
  368.     particle (self.origin+vel*0.01,vel,73,200);
  369. };
  370.  
  371. /*
  372. ==============================
  373. flare_dim()
  374. This function makes the flare
  375. go dim again
  376. ==============================
  377. */
  378.  
  379. void() flare_dim =
  380. {
  381.     self.effects=EF_DIMLIGHT;
  382.     self.nextt